home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
comm
/
ca29_3.zip
/
BBSETUP.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1992-03-24
|
28KB
|
953 lines
SET TTHRU OFF ; Must be 1st line to suppress typethrough
LEGEND "BBS Setup ver 1.0"
;**** TRACE ON ; Debugging
;
; ----- COM-AND BBS setup script
; Commenced: 11/90 R.McG
; -----------------------------------------------------------------------
; Purpose:
; This script, named BBSETUP.CMD, is executed to setup the BBS
; script (version 1.1). Setup 1) identifies the port and modem
; control values, 2) identifies (and creates) the subdirs to be
; used. The script BBMAINT is used to update related files.
; -----------------------------------------------------------------------
; NOTE: This script expects to find a file named BBSDAT on 1) the
; current subdirectory, 2) The COM-AND= environment var specified
; subdirectory, or 3) the subdirectory where THIS script resides.
; If this file is found, it will be overwritten subsequently. If
; NOT found, BBSDAT will be created on the subdir where COM-AND=
; points. S29 is used to keep the file name (subroutine INIT).
; -----------------------------------------------------------------------
;
; Establish a DWINDOW, and change the text display to window default.
; .. Save the previous text display attribute, for restoration later.
;
DWIND 1,2 22,78 ; Establish scrolling region
N99 = "_TEXT" ; Save original text attr
SET TEXT "_DEFA" ; Set text attr
SET FLAG(9) OFF ; Note if we did any saves
;
; Perform tasks
;
GOSUB Init ; Setup initial values
GOSUB Main ; Paint main screen
;*** GOSUB ChkSave ; Check if save needed
GOSUB ChkAll ; Check if subd's exist
;
; Exit the script
;
Escape:
Exit:
SET TEXT N99 ; Reset text attr finally
DWINDOW CLEAR ; Clear any scrolling region
CLEAR ; Clear entire text window
EXIT
; -----------------------------------------------------------------------
; ----- Subroutine: Init -> Set initial values from BBSDAT
; .. NOTE: S29 returns the file name to use for writes to BBSDAT
;
Init:
S20 = "_PARM"(11:14)*","*"_PARM"(0:3) ; Port(4),speed(4)
S21 = "ATE0Q0V1X1S0=2 S7=30 S9=10^M" ; Standard MINIT for BBS
S22 = "\BBS" ; Set to our subdirectory
S23 = "\BBS\FILES" ; Set subdir for files
S24 = "\BBS\MAIL" ; Set subdir for mail
S25 = "\BBS\BULLETIN" ; Set subdir for bulletins
;
; Replace above values from BBSDAT, if that script exists
;
S29 = "" ; Make value null
IF ISSC "BBSDAT" ; If file exists on dft subdir or COM-AND=
FCALL "BBSDAT" ; .. execute it
ELSE
S10 = "_SCRIPT" ; Get current script fname
GOSUB Parse_Fname ; Extract drive:Subdir from name
S10 = S10*"\BBSDAT" ; Make new name
IF ISSC S10 ; Invoke it if its THERE
FCALL S10 ; Invoke it
S29 = S10 ; Save for later
ENDIF
ENDIF
RETURN ; Done init
; -----------------------------------------------------------------------
; Subroutine: Parse drive:subdirectory from file name
;
; S10 passes fully name S10 returns drive:subdirectory
; S11 returns file name
; N10,N11 are scratch values
; -----------------------------------------------------------------------
;
Parse_Fname:
LENGTH S10 N10 ; Find length of string
FOR N11 = (N10-1),0,-1 ; Scan backwards through string
IF STRCMP S10(N11:N11) ":" or STRCMP S10(N11:N11) "\" GOTO PAFN100
ENDFOR
S11 = S10 ; No drive or path
S10 = "" ; Return null drive:path spec
RETURN
;
; Extract drive and path from name; N11 points to ":" or "\"
;
PAFN100:
S11 = S10(N11+1:N10) ; Extract name portion
IF STRCMP S10(N11:N11) "\" DEC N11
S10 = S10(0:N11) ; Save ":", remove last "\"
RETURN
; -----------------------------------------------------------------------
; ----- Subroutine: Save -> Save values in BBSDAT
; .. BBSDAT is placed in dft subdir; create file if need be
;
Save:
IF NULL S29 ; If INIT did not set a name
;
; Construct a file name on the appropriate directory
;
S1 = "" ; Initialize file name string
IF NOT ISFIL "BBSDAT"; If not on current subdir
ENVIRON S1 "COM-AND="; Look for COM-AND= environment var
IF FOUND ; If environment variable found
LENGTH S1 N0 ; Get its length
N0 = N0-1 ; Point to last char in string
IF not STRCMP S1(n0:n0) "\"
N0 = N0+1 ; Point after last char
CONCAT S1(n0) "\"
ENDIF
ENDIF
ENDIF
S1 = S1&"BBSDAT" ; Add the necessary file name
ELSE S1 = S29 ; Else use name set by INIT
;
; Open the file, write the file, and close it
;
FOPENO S1 TEXT ; Open the file name so constructed
IF NOT SUCCESS
S0 = "Error opening BBSDAT file: "*S1
GOSUB Error ; Report
RETURN ; And we're done
ENDIF
S29 = "_OFILE" ; Save file name we opened
;
; Write values we have as of now
;
WRITE "; --- BBS initialization !" ; Write initial comments
WRITE "; Updated "*"_DATE"*", at "*"_TIME"*"!"
WRITE ";!" ; Write initial comments
WRITE "S20=`""*S20&"`"!" ; Write port and speed
S0 = S21 ; Copy control string
PRESERVE S0 ; Make it printable
WRITE "S21=`""*S0&"`"!" ; Write modem control string
WRITE "S22=`""*S22&"`"!"; Write BBS subdir
WRITE "S23=`""*S23&"`"!"; Write BBS files subdir
WRITE "S24=`""*S24&"`"!"; Write BBS mail subdir
WRITE "S25=`""*S25&"`"!"; Write BBS bulletin subdir
WRITE "FRETURN!^Z " ; Write end of file
;
; Close the file and we're done
;
SET FLAG(9) ON ; Note we did ONE save
FCLOSEO ; Close the file
RETURN ; And we're done
; -----------------------------------------------------------------------
; ----- Error: Open a window, display a message, and wait for keypress
; S0 passes the error message
;
Error:
WOPEN 10,10,12,70 (cont) Err_Esc
ATSAY 10,12 (cont) " Error "
ATSAY 11,12 (cont) S0(0:55); Max msg width 55 chars
ATSAY 12,26 (cont) " Press any key to continue "
;
; Wait a keypress
;
KEYGET S0 ; Wait for any key
WCLOSE
Err_Esc:
RETURN
; -----------------------------------------------------------------------
; ----- Subroutine: ChkSave -> Save file?
;
ChkSave:
IF FLAG(9) RETURN ; At least one save was performed
WOPEN 0,0 23,79 (defa) Main_ESC
ATSAY 0,2 (defa) " BBS Save "
ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
CHSA100:
CLEAR ; Clear window
LOCATE 2,2
MESS " Do you wish to save the current values? (y/n) "
MESS "──────────────────────────────────── "
MESS " Port and speed is: "*S20
S0 = S21 ; Copy control string
PRESERVE S0 ; Make it printable
MESS " Modem control is: "*S0
MESS " BBS main subdir is: "*S22
MESS " Files subdir is: "*S23
MESS " Mail subdir is: "*S24
MESS " Bulletin subdir is: "*S25
MESS " "
MESS "──────────────────────────────────── "
MESS "Enter y or n (carriage return = n): "
;
; Wait for a keypress
;
GET S0 1 ; Wait for it
IF NULL S0 GOTO CHSA200 ; If c/r, simply return
SWITCH S0 ; Act according to keyget
CASE "y" ; Case insensitive
GOSUB Save
GOTO CHSA200
ENDCASE
CASE "n" ; Case insensitive
GOTO CHSA200
ENDCASE
DEFAULT ; None of the above
SOUND 100,100 ; Bronx cheer
ENDCASE
ENDSWITCH
GOTO CHSA100 ; Repaint screen and ask again
;
; Exit, closing the window
;
CHSA200:
WCLOSE
RETURN
; -----------------------------------------------------------------------
; ----- Subroutine: ChkAll -> Check for subdir creation req'd
;
ChkAll:
WOPEN 10,10 12,70 (cont)
ATSAY 10,12 (cont) " BBS Subdirs "
ATSAY 11,12 (cont) " Checking existance of subdirs... "
PAUSE 1 ; Make it visible
;
; Test for the existence of all subdirectories
;
SET FLAG(0) ON
FFIRST S22&"\*.*" ; test for Main subd
IF SUCCESS SET FLAG(0) OFF
SET FLAG(1) ON
FFIRST S23&"\*.*" ; test for File subd
IF SUCCESS SET FLAG(1) OFF
SET FLAG(2) ON
FFIRST S24&"\*.*" ; test for Mail subd
IF SUCCESS SET FLAG(2) OFF
SET FLAG(3) ON
FFIRST S25&"\*.*" ; t